package com.example.egmybatis1.mapper;

import com.example.egmybatis1.pojo.entity.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProductMapper {

    @Insert("INSERT INTO product(title,price,stock) " +
            "VALUES(#{title},#{price},#{stock})")
    int insertProduct(Product product);
    @Select("SELECT title,price FROM product WHERE id=#{id} ")
    Product searchProduct(Long id);
    @Delete("DELETE FROM product WHERE id=#{id}")
    int deleteProduct(Long id);
    @Select("SELECT id,title,price,stock FROM product")
    List<Product> selectProduct();
}
